home *** CD-ROM | disk | FTP | other *** search
- Path: raven.eva.net!usenet
- From: joebwan@anv.net (Joe Bostic)
- Newsgroups: comp.lang.c++
- Subject: Did Borland 5.0 break templates (ouch!)
- Date: Sun, 21 Apr 1996 02:02:01 GMT
- Organization: Westwood Studios
- Message-ID: <3179962c.126789194@news.accessnv.com>
- NNTP-Posting-Host: joebwan.anv.net
- X-Newsreader: Forte Agent .99d/32.182
-
- ... or is it just me. I'm trying to use a template that takes an
- integer parameter. I would like to declare the body of the member
- functions outside of the template declaration (a normal and legal
- request). However, the following code fails using Borland 5.0 compiler
- (16 or 32 bit). I've reverted back to 4.52 (which compiles just fine)
- until I know whether I should get mad at Borland or kick myself for
- not understanding some mysterious new 'feature' of the C++ standard
- that Borland is implementing.
-
- ------------ Code to demonstrate problem -----------------------
-
- template<int T>
- class Test {
- public:
- void Simple(void);
- Test const & Foobar(Test const & rvalue);
- Test const & operator | (Test const & rvalue);
- };
-
-
- template<int T>
- void Test<T>::Simple(void)
- {
- }
-
- // "invalid template qualified name" error.
- // if the "Test<T>::" is removed it compiles but linker
- // can't find the "Foobar" function.
- template<int T>
- Test<T> const & Test<T>::Foobar(Test<T> const & rvalue)
- {
- return(*this);
- }
-
- template<int T>
- Test<T> const & operator | (Test<T> const & rvalue)
- {
- return(*this);
- }
-
- void main(void)
- {
- Test<100> x;
-
- x.Foobar(x);
- x = x | x; // Linker can't find function!
- x.Simple(); // No problem with this line.
- }
-